package leecode.test1;

public class Solution1 {
    public static void main(String[] args) {
        System.out.println("begins");
        System.out.println(Thread.currentThread().getName());
        Thread thread = new Thread(new MyRunnable());
        System.out.println(thread.getState());
        System.out.println(thread.getName());
        thread.setDaemon(true);
        thread.start();
        System.out.println(thread.getState());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(thread.getState());
    }
}

class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
        System.out.println("新线程开启");
        Thread.yield();

        System.out.println("新线程结束");
    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
        System.out.println("我是四队的线程");
    }

    void sleep() {
        try {
            sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

